package com.example.lol.ui.adapter;


import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;

import com.example.lol.ui.FirstHomeFragment;
import com.example.lol.ui.FourthHomeFragment;
import com.example.lol.ui.SecondHomeFragment;
import com.example.lol.ui.ThirdHomeFragment;

import java.util.HashMap;
import java.util.Map;

public class HomeAdapter extends FragmentPagerAdapter {

    private Map<Integer, Fragment> data;
    private String[] tabs = {"关注", "推荐", "赛事","云顶","手游"};

    public HomeAdapter(@NonNull FragmentManager fm) {
        super(fm);
        data = new HashMap<>();
        data.put(0, new FirstHomeFragment());
        data.put(1, new SecondHomeFragment());
        data.put(2, new ThirdHomeFragment());
        data.put(3, new FourthHomeFragment());
        data.put(4, new FirstHomeFragment());
    }

    @NonNull
    @Override
    public Fragment getItem(int position) {
        return data.get(position);
    }

    @Override
    public int getCount() {
        return 5;
    }

    @Nullable
    @Override
    public CharSequence getPageTitle(int position) {
            return tabs[position];
    }
}